package com.sx.pipeline.adapter

import android.text.TextUtils
import android.view.View
import android.widget.LinearLayout
import androidx.appcompat.widget.LinearLayoutCompat
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.noober.background.view.BLTextView
import com.sx.pipeline.R
import com.sx.pipeline.repos.http.res.ExamineOperatorVo

class ExamineOperatorAdapter : BaseQuickAdapter<ExamineOperatorVo, BaseViewHolder>
    (R.layout.item_examine_operator, mutableListOf()) {
    override fun convert(holder: BaseViewHolder, item: ExamineOperatorVo) {
        val tabStatus = mutableListOf<String>("未审核", "审核通过", "审核驳回","已取消")
        holder.setText(R.id.tv_time, item.createTime.orEmpty())
        holder.setText(R.id.tv_status, tabStatus[item.status ?: 0])
        holder.getView<LinearLayoutCompat>(R.id.layout_option).visibility= if(item.status==0)View.VISIBLE else View.GONE
        if (!TextUtils.isEmpty(item.avatar)) {
            Glide.with(context).load(item.avatar).into(holder.getView(R.id.image_head))
        }
        holder.setText(R.id.tv_name,item.userName.orEmpty())
        holder.setText(R.id.tv_phone,item.phone.orEmpty())
        holder.getView<BLTextView>(R.id.tv_reject).setOnClickListener{
            getOnItemClickListener()?.onItemClick(this@ExamineOperatorAdapter,it,holder.layoutPosition)
        }
        holder.getView<BLTextView>(R.id.tv_agree).setOnClickListener{
            getOnItemClickListener()?.onItemClick(this@ExamineOperatorAdapter,it,holder.layoutPosition)
        }
        holder.getView<LinearLayoutCompat>(R.id.layout_contain).setOnClickListener{
            getOnItemClickListener()?.onItemClick(this@ExamineOperatorAdapter,it,holder.layoutPosition)
        }
    }
}